<?php
namespace backend\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use yii\filters\VerbFilter;

/**
 * Site controller
 */
class SiteController extends Controller
{

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    public function actionIndex()
    {
       return $this->redirect('index.php?r=site/login');
    }

    public function actionLogin()
    {
        $this->layout = "@app/views/layouts/login.php";
        $model = new LoginForm;
        return $this->render("login",['model'=>$model]);
    }

    public function actionLoginin()
    {
        return $this->redirect('index.php?r=admin/index');
    }

    public function actionLogout()
    {
        Yii::$app->user->logout();

        return $this->goHome();
    }
}
